#pragma once

#include "Containers/Containers.h"

#include "Misc/StdHead.h"

#include "Object/Object.h"
#include "Path/Path.h"


#include "Font.m.h"

struct SFreeTypeGlyph;

enum class EFontStyle
{
    Normal = 0x00,
    Bold   = 0x01,
    Italic = 0x02,
    UnderLine  = 0x04,
    StrikeThrough =0x08,

};


class RFont;


RCLASS()
class WHENGINE_API RFont : public RObject
{
    ROBJECT

    RFont(){};
    ~RFont(){};
public:    
    std::shared_ptr<SFreeTypeGlyph> 
        FindOrCreateGlyph(char32_t InUnicode ,uint32_t InFontSize); 

    //is font support this unicode
    bool SupportChar(char32_t InUnicode);

    //height of one line, is Ascent - Descent
    float GetLineHeight(uint32_t InFontSize);

    //there is three line in font
    //1. Ascent , top line of font
    //2. Descent, bottom line of font
    //3. BaseLine , is the line of character 'x's bottom,
    //              obviously, it is between Ascent and Descent

    //get highest point of font，it is distance from baseline to top, is positive 
    float GetAscent(uint32_t InFontSize);
    //get lowest point of font, it is distance from baseline to bottom, is negative
    float GetDescent(uint32_t InFontSize);

private:
    friend class RFontApplicationSubsystem;

    // type is FT_Face
    void * LowLevelFont=nullptr;

    TMap<TTuple<char32_t /* unicode */ ,uint32_t>,std::shared_ptr<SFreeTypeGlyph>> Glyphs;



};


// all nessasay font info to render text
struct WHENGINE_API SFontInfo
{
    TSharedObjectPtr<RFont> Font;
    uint32_t FontSize=12;
    //EFontStyle Style=EFontStyle::Normal;

};